package com.mrd.config;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

/**
 * 用户过滤器
 * 
 * @author han
 */
@Component
public class UserSecurityInterceptor implements HandlerInterceptor {
  @Override
  public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
      throws Exception {
    // Object obj = request.getSession().getAttribute(SystemConstants.SYS_LOGINSESSION);
    // String uri = request.getRequestURI();
    // if (uri.indexOf("/login") > 0) {
    // return true;
    // } else {
    // if (obj == null || !(obj instanceof SysUserEntity)) {
    // response.sendRedirect(request.getContextPath() + "/login");
    // return false;
    // }
    // }
    return true;
  }

  @Override
  public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
      ModelAndView modelAndView) throws Exception {}

  @Override
  public void afterCompletion(HttpServletRequest request, HttpServletResponse response,
      Object handler, Exception ex) throws Exception {}
}
